﻿//得到所有省
function getProvince(containerId) {
    var url = "/ChinaRegion/GetAllProvince";
    jQuery.ajax({
        url: url,
        type: "get",
        dataType: "json",
        success: function (data) {
            var ops = "<option value='-1'>- 请选择省份 -</option>";
            for (var i in data) {
                ops += "<option value=\"" + data[i].Id + "\">" + data[i].NodeName + "</option>";
            }
            jQuery("#" + containerId).html(ops);
        }
    });
}
//根据省得到该省下的所有市
function getCitiesByProvince(obj, containerId) {
    var provinceId = jQuery(obj).val();
    var url = "/ChinaRegion/GetCitiesByProvince/" ;
    var data = new Object();
    data.id = provinceId;
    jQuery.ajax({
        url: url,
        type: "get",
        data:data,
        dataType: "json",
        success: function (data) {
            var ops = "<option value='-1'>- 请选择城市 -</option>";
            for (var i in data) {
                ops += "<option value=\"" + data[i].Id + "\">" + data[i].NodeName + "</option>";
            }
            jQuery("#" + containerId).html(ops);
        }
    });
}

function setRegion(obj, containerId) {
    var v = jQuery(obj).val();
    jQuery("#" + containerId).val(v);
}